<?php

/**
 * This is the model class for table "appapplicationmodule".
 *
 * The followings are the available columns in table 'appapplicationmodule':
 * @property integer $applicationid
 * @property integer $moduleid
 * @property string $modulename
 * @property string $url
 * @property boolean $isactive
 * @property string $createdby
 * @property string $createdon
 * @property string $lastupdateby
 * @property string $lastupdateon
 *
 * The followings are the available model relations:
 * @property Appapplicationinterfaces[] $appapplicationinterfaces
 * @property Appapplicationinterfaces[] $appapplicationinterfaces1
 * @property Appapplication $application
 * @property Appmenu[] $appmenus
 * @property Appmenu[] $appmenus1
 */
class Appapplicationmodule extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'appapplicationmodule';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('applicationid, moduleid, modulename, createdby, createdon', 'required'),
			array('applicationid, moduleid', 'numerical', 'integerOnly'=>true),
			array('modulename, url, createdby, lastupdateby', 'length', 'max'=>100),
			array('isactive, lastupdateon', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('applicationid, moduleid, modulename, url, isactive, createdby, createdon, lastupdateby, lastupdateon', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'appapplicationinterfaces' => array(self::HAS_MANY, 'Appapplicationinterfaces', 'applicationid'),
			'appapplicationinterfaces1' => array(self::HAS_MANY, 'Appapplicationinterfaces', 'moduleid'),
			'application' => array(self::BELONGS_TO, 'Appapplication', 'applicationid'),
			'appmenus' => array(self::HAS_MANY, 'Appmenu', 'applicationid'),
			'appmenus1' => array(self::HAS_MANY, 'Appmenu', 'moduleid'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'applicationid' => 'Applicationid',
			'moduleid' => 'Moduleid',
			'modulename' => 'Modulename',
			'url' => 'Url',
			'isactive' => 'Isactive',
			'createdby' => 'Createdby',
			'createdon' => 'Createdon',
			'lastupdateby' => 'Lastupdateby',
			'lastupdateon' => 'Lastupdateon',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('applicationid',$this->applicationid);
		$criteria->compare('moduleid',$this->moduleid);
		$criteria->compare('modulename',$this->modulename,true);
		$criteria->compare('url',$this->url,true);
		$criteria->compare('isactive',$this->isactive);
		$criteria->compare('createdby',$this->createdby,true);
		$criteria->compare('createdon',$this->createdon,true);
		$criteria->compare('lastupdateby',$this->lastupdateby,true);
		$criteria->compare('lastupdateon',$this->lastupdateon,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Appapplicationmodule the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
